package cn.itlaobing.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.itlaobing.exception.MyException;
import com.itlaobing.service.UserOrdersService;

import cn.itlaobing.annotation.AnnotationMapping;
import cn.itlaobing.model.UserModel;
import cn.itlaobing.model.UserOrdersModel;

@WebServlet(value="/userorders/*")
public class UserordersServlet extends BaseServlet{
	@AnnotationMapping("/selectByid")
	public void selectByid(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException  
	{
		/*String Id=request.getParameter("id");
		Integer id=Integer.parseInt(Id);*/
		UserModel um=(UserModel)request.getSession().getAttribute("user");
		UserOrdersService uos=new UserOrdersService();
		List<UserOrdersModel> list=null;
		try {
			list=uos.queryAllById(um.getUserId());
		} catch (MyException e) {
			e.printStackTrace();
		}
		request.setAttribute("USERORDERS_LIST", list);
		request.getRequestDispatcher("/WEB-INF/login.jsp").forward(request, response);
	}
}
